The invention relates to optical storage drives, and more particularly, to a method for handling an interrupt request in an optical storage drive that executes a control procedure or an operation that needs a long time.
As computer devices become more popular, the application of computer devices is expanding. In addition to normal business use, personal computers are being used at home for providing functions such as multimedia entertainment. Because multimedia entertainment involves enormous audio and video streams for generating the needed visual and voice effects, the development of data-storage technology has been further promoted. One by one, many different kinds of data-storage devices have appeared for storing the digital data more easily. Among theses data-storage devices, optical discs have been the preferred tool for users to record data in recent years because of the low cost, small volume, and large capacity of optical discs. In addition to the data for normal documents and programs, optical discs are also widely used for storing multimedia data such as audio streams and video streams. An optical storage drive is used for accessing the data stored on the optical discs.
Please refer to FIG.1, which is a diagram of an optical storage drive 120 operating in coordination with a host 110 according to the related art. The optical storage drive 120 couples with the host 110 and receives the control commands from the host 110 to operate. The optical storage drive 120 comprises a control circuit 122 that is used for controlling the operation of the optical storage drive 120. Additionally, a non-volatile storage memory 124 (such as Flash memory), a buffer 126 (such as the volatile RAM or the registers), and a servo module 140 used for achieving the function of the optical storage drive 120 are set up in the optical storage drive 120. The buffer 126 is used for temporarily storing the data that is needed during the operation of the optical storage drive 120. The servo module 140 comprises a spindle motor 142, a pickup head 146, and other mechanical and electrical devices. The spindle motor 142 is used for driving the optical disc 150 to rotate. The pickup head 146 slides along a sliding track 144 to access data of different tracks in the optical disc 150.
Generally speaking, the host 110 sends the high-level control commands to the control circuit 122 of the optical storage drive 120. The control circuit 122 executes the firmware program code 130 stored in the non-violate storage memory 124 according to the control command. The control circuit 122 executes the corresponding control procedure stored in the firmware program code 130 for controlling the servo module 140 to execute the main function of the optical storage drive 120.
For example, the host 110 sends a read command to the optical storage drive 120 and assigns the address of the data in the optical disc 150 when reading the data in the optical disc 150. And then the control circuit 122 executes the firmware program code 130 of the optical storage drive 120 for coordinating the operations of the spindle motor 142, the pickup head 146, and other devices, such as controlling the spindle motor 142 to reach a specific rotational speed and moving the pickup head 146 to a pre-determined track for receiving reflected laser light from the optical disc 150. The data that the servo module 140 reads from the optical disc 150 is temporarily stored in the buffer 126 and is then transferred to the host 110 using the control circuit 122.
Please refer to FIG. 2, which is a flowchart 200 of the optical storage drive 120 reading data from the optical disc 150 according to a read command of the host 110 according to the related art. The flowchart 200 comprises the following stops:
Step 202: The optical storage drive 120 utilizes the control circuit 122 to receive and interpret a read command Instruction_A from the host 110.
Step 204: The optical storage drive 120 executes a read procedure according to the read command Instruction_A.
Step 206: The control circuit 122 is utilized to check whether data indicated by the read command Instruction_A is stored in the buffer. If the indicated data is stored in the buffer, go to step 212, if not, go to step 208.
Step 208: The control circuit 122 is utilized to execute the firmware program code 130 for controlling the servo module 140 to execute seeking operation.
Step 210: The servo module 140 is utilized to read the data indicated by the read command Instruction_A in the optical disc 150 and to temporarily store the data in the buffer 126.
Step 212: The control circuit 122 is utilized to send the corresponding data in the buffer 126 back to the host 110 for responding the read command.
Step 214: The read operation is finished.
The detailed operation of the optical storage drive 120 mentioned above reading the data of the optical disc 150 according to a read command from the host 110 is known by those skilled in the art. For brevity, further details are omitted here.
In general, after the host 110 sends a read command to the optical storage drive 120, the host 110 sends the next read command to the optical storage drive 120 until the optical storage drive 120 returns the data indicated by the read command. When the host 110 needs a great deal of data from the optical disc 150 (ex: video data while playing the optical disc 150), the host 110 continuously sends read commands to the optical storage drive 120 for obtaining the data of the optical disc 150.
In the related art, the optical storage drive 120 often utilizes the buffer 126 to provide a cache function. For example, if the optical disc 150 is a VCD, the data to be read by the host 110 is often continuous video data. After the optical storage drive 120 receives a read command from the host 110, the optical storage drive 120 not only temporarily stores the data indicated by the read command in the buffer 126, but also temporarily stores following data in the buffer 126 so that the optical storage drive 120 is able to perform cache operation when receiving following read commands. This means that when the host 110 sends the read command Instruction_A to the optical storage drive 120 in step 202, the optical storage drive 120 executes step 206 to first examine whether the data indicated by the read command Instruction_A is stored in the buffer 126 or not. If the data to be read is stored in the buffer 126, control moves to step 212 for transferring the data in the buffer 126 to the host 110 to respond the read command Instruction_A. The optical storage drive 120 doesn't need to read the data indicated by the read command Instruction_A from the optical disc 150. Therefore, the speed of the optical storage drive 120 responding to the host 110 is improved.
In the related art, a data quantity threshold is usually set up in the buffer 126 of the optical storage drive 120. After the optical storage drive 120 fills up the buffer 126 to a specific level of the buffer. The data stored in buffer 126 is continuously transferred to the host 110 because of the read commands send by the host 110. As long as the data quantity in the buffer 126 is more than the data quantity threshold, the optical storage drive 120 doesn't need to execute data-renewing. When the data quantity in the buffer becomes equal to or lower than the data quantity threshold, the optical storage drive 120 reads the following data from the optical disc 150 for filling up the data quantity of the buffer 126 to the specific level.
Therefore, in step 206, if the related art judges that the data indicated by the read command Instruction_A is stored in the buffer 126, it also determines whether the data quantity remaining after subtracting the data indicated by the read command Instruction_A is equal to or lower than the data quantity threshold. If the control circuit 122 judges that the remaining data quantity is equal to or lower than the data quantity threshold of the buffer 126 after transferring the data indicated by the read command lnstruction_A to the host 110, the control circuit 122 controls the servo module 140 for reading the following data of the optical disc 150 and temporarily storing the data in the buffer to fill up the data quantity to the specific level of the buffer 126 according to the main loops of the firmware program code 130.
Before reading the data of the optical disc 150, the optical storage drive 120 has to execute a seeking operation to move the pickup head 146 to an appropriate position. The seeking operation is a procedure of moving the pickup head 146 along the sliding track 144 to a track that the data to be read belongs to. The executing time of the seeking operation is usually from several microseconds (ms) to 100 microseconds. A long-seeking operation will spend a multiple of the seeking time. The optical storage drive 120 utilizes the cache function provided by the buffer 126 to smooth the procedure of data transferring. Only if the data to be read is not in the buffer 126, or only if parts of the data to be read are in the buffer 126 and the other part of the data to be read have to be read from the optical disc 150, will the optical storage drive 120 have to execute the seeking operation of step 208.
However, in the structure of the firmware program code 130 of the optical storage drive 120 according to the related art, when the optical storage drive 120 executes the seeking operation of step 208 according to the main loop of the firmware program code 130, if the optical storage drive 120 receives a read command Instruction_B send by the host 110, the interrupt request will be generated. After accepting parameters of command, the interrupt request will be temporarily paused. Only when the control circuit 122 has completed the routine procedure (step 208) according to the main loop of the firmware program code 130 will the optical storage drive 120 respond to the interrupt request to interpret and handle the read command Instruction_B. Actually, not only in the seeking operation, but the interrupt request is also paused in all handling methods of the interrupt request when the optical storage drive 120 executes a control procedure or operation that needs a long time in the structure of the firmware program code 130. After the procedure or operation completed, the optical storage drive 120 executes the new interrupt procedure. For example, the operations of normal optical storage drives such as modulating the rotating speed of the spindle motor 142, retrying, and so on, are all control procedures or operations that need a long time.
As known in the related art, the responding speed of the optical storage drive 120 to a read command is much faster than the speed of the optical storage drive 120 executing a seeking operation. For example, the speed of the host 110 transferring data through the IDE or SCSI bus interface is 10 M bytes/second, but the data length requested by each read command send by the host 110 is 20 k bytes. This means that the response time of the optical storage drive 120 to a read command is only 2 milliseconds (ms).
In other words, if the host 110 sends the read command Instruction_B to the optical storage drive 120 during executing the control procedure or operation that needs a longer time in the optical storage drive 120, the read command Instruction_B is responded to after the optical storage drive 120 completes the preceding procedure. So, even if the data indicated by the read command Instruction_B is stored in the buffer 126, the optical storage drive 120 still has to wait until the control procedure or operation is completed and then the optical storage drive 120 responds to the interrupt request. This means the host 110 may cause delays due to the interruption of data. For example, in the related art, when the host 110 utilizes the optical storage drive 120 to read the data of a VCD for playing a video, if the data that the host 100 needs is interrupt, a severe problem such as a delay could occur.
In order to reduce the influence of a delay, the prior applies the State Machine method of the program design to design the firmware program code 130. The State Machine method divides the control procedure or operation that needs a long time of the optical storage drive 120 into many stages for executing. So, the time of each state may be much lower, and the optical storage drive 120 can utilize the interval of states to handle the interrupt request corresponding to the read command send by the host 110 for reducing the time of the read command waiting to be responded.
However, the firmware program code where the State Machine method is utilized is a little complicated so that the difficulties and the cost of updating and maintaining the firmware program code increases. It further influences the timing of products getting into the market.